<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>申请人列表</title>
    <link rel="stylesheet" href="/static/admin/plugins/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/static/admin/css/global.css" media="all">
    <link rel="stylesheet" href="/static/admin/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/static/admin/css/table.css"/>
    <link rel="stylesheet" href="/static/admin/js/plugins/zTree/zTreeStyle.css" type="text/css">
</head>

<body>
<div class="admin-main">

    <blockquote class="layui-elem-quote">
        <form class="layui-form">
            <div class="layui-form">
                <div class="layui-inline">
                    <div class="layui-input-inline" style="width: 150px;">
                        <input class="layui-input" id="dataName" placeholder="关键字">
                    </div>
                </div>
                <div class="layui-inline">
                    <select name="activity_id" id="dataActivity">
                        <option value="">请选择类型</option>
                        {foreach name="activity" item="v" key="k"}
                        <option value="{$v.id}">{$v.title}</option>
                        {/foreach}
                    </select>
                </div>
                <div class="layui-inline">
                    <button id="search" type="button" class="layui-btn"><i class="layui-icon">&#xe615;</i> 查找</button>
                </div>
            </div>
        </form>
    </blockquote>
    <fieldset class="layui-elem-field">
        <legend>申请人列表</legend>
        <div class="layui-field-box">
            <table class="site-table table-hover">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>用户</th>
                    <th>关联活动</th>
                    <th>宝宝信息</th>
                    <th>宝宝图片</th>
                    <th>票数</th>
                    <th>状态</th>
                </tr>
                </thead>
                <tbody id="con">

                </tbody>
            </table>

        </div>
    </fieldset>
    <div class="admin-table-page">
        <div id="page" class="page">
        </div>
    </div>
</div>
<script type="text/javascript" src="/static/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/admin/plugins/layui/layui.js"></script>
<script type="text/javascript" src="/static/admin/js/layeralert.js"></script>
<script type="text/javascript" src="/static/admin/js/plugins/zTree/jquery.ztree.core-3.5.js"></script>
<script type="text/javascript" src="/static/admin/js/plugins/zTree/jquery.ztree.excheck-3.5.js"></script>
<script type="text/javascript" src="/static/admin/js/plugins/zTree/jquery.ztree.exedit-3.5.js"></script>
<!--模板 <a href="./edit/id/{{item.id}}" class="layui-btn layui-btn-small"><i class="layui-icon"></i></a> -->
<script type="text/html" id="conTemp">
    {{# layui.each(d.list, function(index, item){ }}
    <tr>
        <td>{{ item.id }}</td>
        <td>{{ item.user_id_format }}</td>
        <td>{{ item.aid_format }}</td>
        <td>
            姓名：{{ item.baby_name }} <br>
            年龄：{{ item.age }}
        </td>
        <td>
            <img src="{{ item.picture }}" style="max-height: 80px;" >
            {{# if(item.picture_two) { }}
            <img src="{{ item.picture_two }}" style="max-height: 80px;" >
            {{# } }}
        </td>
        <td>{{ item.poll }}</td>
        {{# if(item.status == 1) { }}
        <td><em class="on-off on" data-url="/apply/editStatus/apply_id/{{ item.id }}" data-key="status" data-value="1,2"></em></td>
        {{# } else { }}
        <td><em class="on-off" data-url="/apply/editStatus/apply_id/{{ item.id }}" data-key="status" data-value="1,2"></em></td>
        {{# } }}
    </tr>
    {{# }); }}
</script>
<script>
    layui.config({
        base: '/static/admin/plugins/layui/modules/'
    });
    var layer, paging;
    layui.use(['icheck', 'layer', 'paging', 'form', 'laydate'], function () {
        layer = layui.layer;
        paging = layui.paging();
        $('input').iCheck({
            checkboxClass: 'icheckbox_flat-green'
        });

        paging.init({
            url: '/apply/index', //地址
            elem: '#con', //内容容器
            optionsId: ['dataName', 'dataActivity'],
            tempElem: '#conTemp', //模块容器
            pageConfig: { //分页参数配置
                elem: '#page', //分页容器
                pageSize: 14 //分页大小
            },
            success: function () { //渲染成功的回调
                //alert('渲染成功');
            },
            fail: function (msg) { //获取数据失败的回调
                //alert('获取数据失败')
            },
            complate: function () { //完成的回调
                //alert('处理完成');
            }
        });

    });
    $(function () {
        $('body').on('click', '.on-off', function () {
            var thisObj = $(this);
            var url = thisObj.data('url');
            var key = thisObj.data('key');
            var val = thisObj.data('value').split(",");
            var value = val[0];
            if(thisObj.hasClass('on')) value = val[1];
            $.post(url, {key: key, value: value}, function(data) {
                layer.msg(data.msg);
                if(data.code == 1) thisObj.toggleClass('on');
            })
        })
    })
</script>
</body>

</html>
